<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no" />
    <link rel="stylesheet" href="__CSS__/common.css">
    <link rel="stylesheet" href="__CSS__/login.css">
    <title>登录</title>
</head>
<body class="black">
    <div class="login-box">
        <form method="post" action="{:url('login/login')}">
        <dl class="buf_item">
            <dt>手机号</dt>
            <dd>
                <input type="text" id="phone" name="mobile">
            </dd>
        </dl>
        <dl class="buf_item">
            <dt>密码</dt>
            <dd>
                <input type="password" id="upwd" name="password">
            </dd>
        </dl>
        </form>
    </div>

    <button class="btn" onclick="return login();">登 录</button>
    <div class="update">
        <a href="update.html">修改密码</a>
        <a href="forget.html">忘记密码？</a>
    </div>
</body>
<script src="__JS__/jquery.min.js"></script>
<script src="__JS__/layer.js"></script>
<script src="__JS__/login.js"></script>
<script type="text/javascript">
function login() {
    var phone=$('#phone').val().trim();
    var phoneReg=/^[0-9]{11}$/;
    var upwd=$('#upwd').val().trim();
    if(!phone){layer.msg("请输入手机号",{time:1500})}
    else if(!phoneReg.test(phone)){
        layer.msg("请输入正确的手机号码", {time: 1500})
    }else if(!upwd){layer.msg("请输入密码",{time:1500})}
    else{
        $.ajax({
            type:'post',
            url:$("form").attr('action'),
            data:$("form").serialize(),
            success:function (data){
                if(data.code==1){
                    layer.msg("登录成功",{time:1500});
                    location.href='{:url("index/index")}'
                }else{
                    layer.msg(data.msg,{time:1500});
                }
            },
            error:function () {

            }

        })
    }
    return false;
}
</script>
</html>